﻿<%@ Page Title="Create interview" Language="C#" MasterPageFile="~/Employee/MasterPageEmployee.master" AutoEventWireup="true" CodeFile="CreateInterview.aspx.cs" Inherits="Employee_CreateInterview" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <link type="text/css" href="Styles/EmployeeStyleSheet.css" rel="Stylesheet" />
    <script type="text/javascript" src="../Scripts/jquery.js"></script>
    <script type="text/javascript" src="../Scripts/jquery-1.2.6.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#<%=ddltitlevacancy.ClientID %>').blur(function () {
                if ($('#<%=ddltitlevacancy.ClientID %>').val() == "Please choise title vacancy") {
                    $('#<%=lblErrortitlevacancy.ClientID %>').html("(*)");
                }
                else {
                    $('#<%=lblErrortitlevacancy.ClientID %>').html("");
                }
                hidebutton();
            });
            $('#<%=ddlApplicant.ClientID %>').blur(function () {
                if ($('#<%=ddlApplicant.ClientID %>').val() == "Please choise Applicant") {
                    $('#<%=lblErrorApplicant.ClientID %>').html("(*)");
                }
                else {
                    $('#<%=lblErrorApplicant.ClientID %>').html("");
                }
                hidebutton();
            });
            $('#<%=ddlInterviewer.ClientID %>').blur(function () {
                if ($('#<%=ddlInterviewer.ClientID %>').val() == "Please choise Interviewer") {
                    $('#<%=lblErrorInterviewer.ClientID %>').html("(*)");
                }
                else {
                    $('#<%=lblErrorInterviewer.ClientID %>').html("");
                }
                hidebutton();
            });
            $('#<%=txtDateInterview.ClientID %>').blur(function () {
                if ($('#<%=txtDateInterview.ClientID %>').val() == "") {
                    $('#<%=lblErrorDateInterview.ClientID %>').html("(*)");
                    ShowHideTitleVacancy();
                }
                else {
                    $('#<%=lblErrorDateInterview.ClientID %>').html("");
                    ShowHideTitleVacancy();
                }
                hidebutton();
            });
            $('#<%=txtHours.ClientID %>').blur(function () {
                if ($('#<%=txtHours.ClientID %>').val() == "") {
                    $('#<%=txtHours.ClientID %>').val("Hours");
                    $('#<%=lblErrorTime.ClientID %>').html("(*)");
                }
                else if ($('#<%=txtMinutes.ClientID %>').val() == "Minutes") {
                    $('#<%=lblErrorTime.ClientID %>').html("(*)");
                }
                else {
                    $('#<%=lblErrorTime.ClientID %>').html("");
                }
                hidebutton();
                ShowHideTitleVacancy();
            });
            $('#<%=txtHours.ClientID %>').focus(function () {
                if ($('#<%=txtHours.ClientID %>').val() == "Hours") {
                    $('#<%=txtHours.ClientID %>').val("");
                }
            });
            $('#<%=txtMinutes.ClientID %>').blur(function () {
                if ($('#<%=txtMinutes.ClientID %>').val() == "") {
                    $('#<%=txtMinutes.ClientID %>').val("Minutes");
                    $('#<%=lblErrorTime.ClientID %>').html("(*)");
                }
                else if ($('#<%=txtHours.ClientID %>').val() == "Hours") {
                    $('#<%=lblErrorTime.ClientID %>').html("(*)");
                }
                else {
                    $('#<%=lblErrorTime.ClientID %>').html("");
                }
                hidebutton();
                ShowHideTitleVacancy();
            });
            $('#<%=txtMinutes.ClientID %>').focus(function () {
                if ($('#<%=txtMinutes.ClientID %>').val() == "Minutes") {
                    $('#<%=txtMinutes.ClientID %>').val("");
                }
            });

            function hidebutton() {
                if ($('#<%=ddltitlevacancy.ClientID %>').val() == "Please choise title vacancy") {
                    $('#<%=btnCreate.ClientID %>').attr('disabled', true);
                }
                else if ($('#<%=ddlApplicant.ClientID %>').val() == "Please choise Applicant") {
                    $('#<%=btnCreate.ClientID %>').attr('disabled', true);
                }
                else if ($('#<%=ddlInterviewer.ClientID %>').val() == "Please choise Interviewer") {
                    $('#<%=btnCreate.ClientID %>').attr('disabled', true);
                }
                else if ($('#<%=txtDateInterview.ClientID %>').val() == "") {
                    $('#<%=btnCreate.ClientID %>').attr('disabled', true);
                }
                else if (($('#<%=txtHours.ClientID %>').val() == "Hours") || ($('#<%=txtMinutes.ClientID %>').val() == "Minutes")) {
                    $('#<%=btnCreate.ClientID %>').attr('disabled', true);
                }
                else {
                    $('#<%=btnCreate.ClientID %>').attr('disabled', false);
                    $('#<%=lblError.ClientID %>').html("");
                }
            };

            function ShowHideTitleVacancy() {
                if (($('#<%=txtDateInterview.ClientID %>').val() != "") && ($('#<%=txtHours.ClientID %>').val() != "Hours") && ($('#<%=txtMinutes.ClientID %>').val() != "Minutes")) {
                    $.ajax({
                        type: "POST",
                        url: "CreateInterview.aspx/CheckDateTime",
                        data: "{'_Date':'" + $("#<%=txtDateInterview.ClientID %>").val() + "', '_Hours':'" + $("#<%=txtHours.ClientID %>").val() + "', '_Minutes':'" + $("#<%=txtMinutes.ClientID %>").val() + "'}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (message) {
                            if (message.d == true) {
                                $('#<%=ddltitlevacancy.ClientID %>').attr('disabled', false);
                            }
                            else {
                                $('#<%=ddltitlevacancy.ClientID %>').attr('disabled', true);
                                $('#<%=ddlApplicant.ClientID %>').attr('disabled', true);
                                $('#<%=ddlInterviewer.ClientID %>').attr('disabled', true);
                                $('#<%=btnCreate.ClientID %>').attr('disabled', true);
                                $('#<%=lblError.ClientID %>').html("Check Date and time of interview.");
                            }
                        },
                        error: function (error) {
                            $('#<%=ddltitlevacancy.ClientID %>').attr('disabled', true);
                            $('#<%=ddlApplicant.ClientID %>').attr('disabled', true);
                            $('#<%=ddlInterviewer.ClientID %>').attr('disabled', true);
                            $('#<%=btnCreate.ClientID %>').attr('disabled', true);
                        }
                    });
                }
                else {
                    $('#<%=ddltitlevacancy.ClientID %>').attr('disabled', true);
                    $('#<%=ddlApplicant.ClientID %>').attr('disabled', true);
                    $('#<%=ddlInterviewer.ClientID %>').attr('disabled', true);
                }
            };
        });
    </script>
    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="contentmain" Runat="Server">
    <div id="Main">
        <h2>Create a new Interview</h2>
        <p class="LineOdd">
            <asp:Label ID="lblDateInterview" runat="server" Text="Date Interview:" 
                Height="20px" Width="180px" CssClass="lblTitleCss"></asp:Label>
            <asp:TextBox ID="txtDateInterview" runat="server" CssClass="CVinput" 
                Height="20px" Width="200px"></asp:TextBox>
            <asp:CalendarExtender ID="txtDateInterview_CalendarExtender" runat="server" 
                TargetControlID="txtDateInterview">
            </asp:CalendarExtender>
            <asp:Label ID="lblErrorDateInterview" runat="server" ForeColor="Red"></asp:Label>
        </p>
        <p>
            <asp:Label ID="lblTimeDetails" runat="server" Text="Time Details:" 
                Height="20px" Width="180px" CssClass="lblTitleCss"></asp:Label>
            <asp:TextBox ID="txtHours" runat="server" CssClass="CVinput" 
                Width="95px">Hours</asp:TextBox><b> :</b>
            <asp:TextBox ID="txtMinutes" runat="server" 
                Width="91px">Minutes</asp:TextBox>
                <asp:Label ID="lblErrorTime" runat="server" ForeColor="Red"></asp:Label>
        </p>
        <p class="LineOdd">
            <asp:Label ID="lblVacancy" runat="server" Height="20px" 
                Width="180px" CssClass="lblTitleCss" Text="Title Vacancy:"></asp:Label>
            <asp:DropDownList ID="ddltitlevacancy" runat="server" 
                CssClass="CVinput" Height="20px" Width="204px" AutoPostBack="True" 
                onselectedindexchanged="ddltitlevacancy_SelectedIndexChanged">
                <asp:ListItem Selected="True">Please choise title vacancy</asp:ListItem>
            </asp:DropDownList>
            <asp:Label ID="lblErrortitlevacancy" runat="server" ForeColor="Red"></asp:Label>
        </p>
        <p>
            <asp:Label ID="lblAplicant" runat="server" Text="Applicant Name:" Height="20px" 
                Width="180px"  CssClass="lblTitleCss"></asp:Label>
            <asp:DropDownList ID="ddlApplicant" runat="server" Height="20px" Width="204px">
                <asp:ListItem Selected="True">Please choise Applicant</asp:ListItem>
            </asp:DropDownList>
            <asp:Label ID="lblErrorApplicant" runat="server" ForeColor="Red"></asp:Label>
        </p>
        <p  class="LineOdd">
            <asp:Label ID="lblInterviewer" runat="server" Text="Interviewer:" Height="20px" 
                Width="180px" CssClass="lblTitleCss"></asp:Label>
            <asp:DropDownList ID="ddlInterviewer" runat="server" Height="20px" 
                Width="204px">
                <asp:ListItem Selected="True">Please choise Interviewer</asp:ListItem>
            </asp:DropDownList>
            <asp:Label ID="lblErrorInterviewer" runat="server" ForeColor="Red"></asp:Label>
        </p>

        <p>
            <asp:Label ID="lblEmployeeCreate" runat="server" Text="Employee Create:" 
                Height="20px" Width="180px" CssClass="lblTitleCss"></asp:Label>
            <asp:TextBox ID="txtEmployeeCreate" runat="server" CssClass="CVinput" 
                Width="200px" Enabled="False"></asp:TextBox>
        </p>
        <p class="LineOdd">
            <asp:Label ID="lblStatus" runat="server" Text="Status:" Height="20px" 
                Width="180px" CssClass="lblTitleCss"></asp:Label>
            <asp:DropDownList ID="ddlStatus" runat="server" CssClass="CVinput" 
                Height="20px" Width="200px" Enabled="False">
                <asp:ListItem Selected="True">Suspeded</asp:ListItem>
            </asp:DropDownList>
        </p>
        <p style="text-align: center;"><asp:Label ID="lblError" runat="server" Text="" ForeColor="Red"></asp:Label>
            <asp:Label ID="lblSuccess" runat="server" ForeColor="Blue"></asp:Label>
        </p>
        <p id="button">
            <asp:Button ID="btnCreate" runat="server" Text="Create" Height="30px" 
                Width="100px" onclick="btnCreate_Click" ToolTip="Create new Vacancy" />
            <asp:Button ID="btnClear" runat="server" Text="Clear" Height="30px" 
                Width="100px" onclick="btnClear_Click" ToolTip="Clear all textbox" />
        </p>
    </div>
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
</asp:Content>

